package com.tradeplus.admin.dao;

import com.tradeplus.admin.model.Wallpaper;
import java.util.List;
import org.springframework.orm.hibernate3.HibernateTemplate;

public class WallpaperDaoImpl implements WallpaperDao {
    
    private HibernateTemplate hibernateTemplate;

    public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
        this.hibernateTemplate = hibernateTemplate;
    }

    @Override
    public void deleteWallpaper(Long wallpaperId) {
        hibernateTemplate.delete(hibernateTemplate.get(Wallpaper.class, wallpaperId));
    }

    @Override
    public List<Wallpaper> loadWallpaper() {
        return hibernateTemplate.find("from Wallpaper");
    }

    @Override
    public Wallpaper loadWallpaperId(Long wallpaperId) {
        return (Wallpaper) hibernateTemplate.get(Wallpaper.class, wallpaperId);
    }

    @Override
    public void saveWallpaper(Wallpaper wallpaper) {
        hibernateTemplate.merge(wallpaper);
    }
    
}
